import Vue from "vue";
import VueRouter from "vue-router";
import Layout from "../components/Layout/index_page.vue";

Vue.use(VueRouter);

const children_routes = [
  {
    path: "/footballManagement/home-page",
    name: "home-page",
    meta: {
      title: "首页",
    },
    component: () => import("@/views/home/index.vue"),
  },
  {
    path: "/footballManagement/player",
    redirect: "/footballManagement/player/list",
    name: "player-index",
    meta: {
      title: "球员管理",
    },
    component: () => import("@/views/player/index.vue"),
    children: [
      {
        path: "/footballManagement/player/list",
        name: "player-list",
        meta: {
          title: "球员管理列表",
          parentName: "player-index",
        },
        component: () => import("@/views/player/list.vue"),
      },
      {
        path: "/footballManagement/player/detail",
        name: "player-detail",
        meta: {
          parentName: "player-index",
          title: "球员详情",
        },
        component: () => import("@/views/player/detail.vue"),
        hidden: true,
      },
      {
        path: "/footballManagement/player/add",
        name: "player-add",
        meta: {
          parentName: "player-index",
          title: "新增球员",
        },
        component: () => import("@/views/player/addAndEdit.vue"),
        hidden: true,
      },
      {
        path: "/footballManagement/player/edit",
        name: "player-edit",
        meta: {
          parentName: "player-index",
          title: "编辑球员",
        },
        component: () => import("@/views/player/addAndEdit.vue"),
        hidden: true,
      },
    ],
  },
  {
    path: "/footballManagement/race",
    redirect: "/footballManagement/race/list",
    name: "race-index",
    meta: {
      title: "比赛管理",
    },
    component: () => import("@/views/race/index.vue"),
    children: [
      {
        path: "/footballManagement/race/list",
        name: "race-list",
        meta: {
          title: "比赛管理列表",
          parentName: "race-index",
        },
        component: () => import("@/views/race/list.vue"),
      },
      {
        path: "/footballManagement/race/detail",
        name: "race-detail",
        meta: {
          title: "比赛详情",
          parentName: "race-index",
        },
        component: () => import("@/views/race/detail.vue"),
        hidden: true,
      },
      {
        path: "/footballManagement/race/add",
        name: "race-add",
        meta: {
          title: "新增比赛",
          parentName: "race-index",
        },
        component: () => import("@/views/race/addAndEdit.vue"),
        hidden: true,
      },
      {
        path: "/footballManagement/race/edit",
        name: "race-edit",
        meta: {
          title: "编辑比赛",
          parentName: "race-index",
        },
        component: () => import("@/views/race/addAndEdit.vue"),
        hidden: true,
      },
    ],
  },
  {
    path: "/footballManagement/dashboard",
    name: "dashboard",
    meta: {
      title: "数据看板",
    },
    component: () => import("@/views/dashboard/index.vue"),
  },
];

const routes = [
  {
    path: "/",
    redirect: "/footballManagement",
  },
  {
    path: "/footballManagement",
    redirect: "/footballManagement/home-page",
    name: "layout",
    component: Layout,
    children: children_routes,
  },
];

const router = new VueRouter({
  routes,
});

export const routesList = children_routes;

export default router;
